Obtaining Java References
In some cases, you may need to access the actual Java objects used in a session, rather than the encapsulated objects passed by the embedding application. For example, if you wanted to call a method contained in an instantiated frame, you would need a reference to the actual Java frame, not theJMFrameRef
object. Table 1-2 lists the functions you can use to return Java references. These functions all return a pointer of typejref
.
Table 1-2 Functions that return pointers to Java objects Function Returns pointer to object JMGetSessionObject
com.apple.mrj.JManager.JMSession
JMGetAwtContextObject
com.apple.mrj.JManager.AWTContext
JMGetAppletViewerObject
com.apple.mrj.JManager.JMAppletViewer
JMGetJMFrameObject
com.apple.mrj.JManager.JMFrame
JMGetAppletObject
java.applet.Applet
JMGetAWTFrameObject
java.awt.Frame
The first four functions return the
jref
equivalents of the corresponding JManager objects. For example,JMGetSessionObject
returns the equivalent of theJMSessionRef
reference.JMGetAppletObject
andJMGetAWTFrameObject
, however, return references to their actual Java objects.You can use these references directly if you are accessing the Java Runtime Interface (JRI), but if you need to access the Java Native Interface (JNI), you must convert references of type
jref
to ones of typejobject
using theJMJRIRefToJNIObject
function. To convert references of typejobject
to typejref
, use theJMJNIObjectToJRIRef
function.